package com.example.demo.lock;

import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

public class Re implements Runnable {

   static Lock lock = new ReentrantLock();
   static Condition condition1 = lock.newCondition();
   static Condition condition2 = lock.newCondition();
   static volatile boolean flag = false;
   static int[] nums = {1,2,3,4,5};

   static String[] strings = {"a","b","c","d","e"};


    @Override
    public void run() {

    }

    public static void main(String[] args) {

        new Thread(()->{
            for (String s:strings){
                while (!flag){}
                System.out.println(s);
                flag = false;

            }
        }).start();

        new Thread(()->{
            for (int num:nums) {
                while (flag){

                }
                System.out.println(num);
                flag = true;

            }
        }).start();

    }
}

class t{

    public static void main(String[] args) {
        int i = 1;
        while (true){

        }
    }
}